<?php
 if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Class User extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
        //$this->checkAdmin($this->session->userdata('admin_id'));
        $this->data['controller'] = 'user';         
        $this->load->model('Muser');
    }
    
    public function login()
    {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', 'Tên đăng nhập', 'required');
        $this->form_validation->set_rules('password', 'Mật khẩu', 'required');
        
        if($this->form_validation->run() === TRUE)
        {
            $this->data['login'] = $this->Muser->loginAdmin();
            if($this->data['login'] = 200)
            {
                redirect('');
            }   
        }
        
        $this->load->view('template/login/index', $this->data);
        
    }
    
    public function logout()
    {
        $this->session->sess_destroy();
        redirect('manage/login');
    }
    
}
